In all cases, move the creation of a new transaction outside of the block
authoremellor@ewan <emellor@ewan>
Sun, 18 Sep 2005 09:09:22 +0000 (10:09 +0100)
committeremellor@ewan <emellor@ewan>
Sun, 18 Sep 2005 09:09:22 +0000 (10:09 +0100)
handling exceptions raised inside that transaction.  If the creation (start) of
the transaction fails, then t has not been assigned, and in any case no
transaction has been created, so it is wrong to attempt to abort that
(non-existent) transaction.

Signed-off-by: Ewan Mellor <ewan@xensource.com>
tools/python/xen/xend/xenstore/xstransact.py

index 3c56251659ea99cc2bf9c33ff0c1bc311a31f865..d76dd88a90ad392f0ca791e35d3b5dd40c4262b7 100644 (file)
@@ -151,8 +151,8 @@ class xstransact:
 
     def Read(cls, path, *args):
         while True:
+            t = cls(path)
             try:
-                t = cls(path)
                 v = t.read(*args)
                 t.commit()
                 return v
@@ -170,8 +170,8 @@ class xstransact:
 
     def Write(cls, path, *args, **opts):
         while True:
+            t = cls(path)
             try:
-                t = cls(path)
                 t.write(*args, **opts)
                 t.commit()
                 return
@@ -189,8 +189,8 @@ class xstransact:
 
     def Remove(cls, path, *args):
         while True:
+            t = cls(path)
             try:
-                t = cls(path)
                 t.remove(*args)
                 t.commit()
                 return
@@ -208,8 +208,8 @@ class xstransact:
 
     def List(cls, path, *args):
         while True:
+            t = cls(path)
             try:
-                t = cls(path)
                 v = t.list(*args)
                 t.commit()
                 return v
@@ -227,8 +227,8 @@ class xstransact:
 
     def Gather(cls, path, *args):
         while True:
+            t = cls(path)
             try:
-                t = cls(path)
                 v = t.gather(*args)
                 t.commit()
                 return v
@@ -246,8 +246,8 @@ class xstransact:
 
     def Store(cls, path, *args):
         while True:
+            t = cls(path)
             try:
-                t = cls(path)
                 v = t.store(*args)
                 t.commit()
                 return v